#ifndef _GN1640_H__
#define _GN1640_H__

#include "config.h"
#include <intrins.h> 

#define GN1640_CLK  P15
#define GN1640_DATA P14

#define T_CLK_HIGH()       NOP20()
#define T_CLK_LOW()        NOP20()
#define T_SETUP()          NOP4()
#define T_HOLD()           NOP4()
#define POS_MINUS          BIT0
#define POS_POINT          BIT1
#define POS_INFOR          BIT2
#define POS_SYSTEM         BIT3
#define ERR_ITEM            40
typedef char  SegCode_t;
typedef struct 
{   
    SegCode_t *num1;
    SegCode_t *num2;
    SegCode_t *unit1;
    SegCode_t *num3;
    SegCode_t *num4;
    SegCode_t *unit2;
    SegCode_t *top;
    SegCode_t *bottom;
    SegCode_t *display1;
    SegCode_t *display2;
}PosCtrl_t;

void GN1640_Init();
SegCode_t GetAsciiCode(char c);
void DisplayNumber(uint8_t num, uint8_t pos) ;
void GN1640_Refresh(void);
void DisplayNumber(uint8_t num, uint8_t pos);
void DisplayStr(char str, uint8_t pos);
SegCode_t FindNumIndexFromSEG(uint8_t num);
void GN1640_ClearRAM();

extern PosCtrl_t posCtrl;
extern SegCode_t *WritableList[];
extern const SegCode_t SEG_CODE[];

#endif  /* _GN1640_H__ */
